#include<bits/stdc++.h>

using namespace std;

void reverse(int R[], int from, int to) {
    for (int i = 0; i < (to - from) / 2; i++) {
        int temp = R[from + i];
        R[from + i] = R[to - i - 1];
        R[to - i - 1] = temp;
    }
}

void converse(int R[], int n, int p) {
    reverse(R, 0, p);
    reverse(R, p, n);
    reverse(R, 0, n);
}

int main() {
    //  测试
    int n = 7, p = 3;
    int R[] = {1, 2, 3, 4, 5, 6, 7};
    converse(R, n, p);
    for (int num : R) {
        cout << num << " ";
    }
    return 0;
}